package com.weiyi.chat.common.base;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2016/12/2.
 */

public abstract class BaseFragment extends Fragment
{
    public BaseActivity mContext;
    private Unbinder unbinder;

    public abstract int getLayoutId();
    public abstract void initViews();
    public abstract void initLoadData();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View views = inflater.inflate(getLayoutId(), container, false);
        mContext = (BaseActivity) getActivity();
        return views;
    }
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        unbinder = ButterKnife.bind(this, view);
        initViews();
        initLoadData();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }


    /**
     * 抽取积累的方法跳转界面
     */
    protected void jumpToActivity(Class<? extends Activity> actClass) {
        Intent intent = new Intent(mContext, actClass);
        startActivity(intent);
    }
}
